﻿using System;
using System.Windows.Forms;

using ProgressSpace;

namespace TravWinControllerSpace
{
    public class ProgressDialogWinView : IProgressPresenter
    {
        private ProgressDialogWinController controller;
        private ProgressModelView modelView;

        internal ProgressDialogWinView (ProgressDialogWinController progressDialogView, ProgressModelView progressModelView)
        {
            this.controller = progressDialogView;
            this.modelView = progressModelView;

            controller.Text = modelView.Title;
        }


        public ProgressResult Show ()
        {
            DialogResult result = controller.ShowDialog ();

            if (result == DialogResult.Cancel)
                return ProgressResult.Cancel;
            else
                return ProgressResult.TaskComplete;
        }

        public void Close ()
        {
            controller.DialogResult = DialogResult.OK;
        }

        public void SetText (string text)
        {
            controller.caption.Text = text;
        }

        public void SetMeter (int percent)
        {
            controller.progressBar.Value = percent;
        }
    }
}
